.class public Lcom/hyphenate/chat/EMChatRoomManager;
.super Ljava/lang/Object;


# instance fields
.field chatRoomListenerImpl:Lcom/hyphenate/chat/adapter/EMAChatRoomManagerListener;

.field private chatRoomListeners:Ljava/util/List;

.field private chatRooms:Ljava/util/List;

.field emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

.field mClient:Lcom/hyphenate/chat/EMClient;

.field private threadPool:Ljava/util/concurrent/ExecutorService;


# direct methods
.method public constructor <init>(Lcom/hyphenate/chat/EMClient;Lcom/hyphenate/chat/adapter/EMAChatRoomManager;)V
    .locals 2

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    invoke-static {v0}, Ljava/util/Collections;->synchronizedList(Ljava/util/List;)Ljava/util/List;

    move-result-object v0

    iput-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListeners:Ljava/util/List;

    const/4 v0, 0x0

    iput-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->threadPool:Ljava/util/concurrent/ExecutorService;

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    invoke-static {v0}, Ljava/util/Collections;->synchronizedList(Ljava/util/List;)Ljava/util/List;

    move-result-object v0

    iput-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    new-instance v0, Lcom/hyphenate/chat/EMChatRoomManager$6;

    invoke-direct {v0, p0}, Lcom/hyphenate/chat/EMChatRoomManager$6;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;)V

    iput-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListenerImpl:Lcom/hyphenate/chat/adapter/EMAChatRoomManagerListener;

    iput-object p2, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    iget-object v1, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListenerImpl:Lcom/hyphenate/chat/adapter/EMAChatRoomManagerListener;

    invoke-virtual {v0, v1}, Lcom/hyphenate/chat/adapter/EMAChatRoomManager;->addListener(Lcom/hyphenate/chat/adapter/EMAChatRoomManagerListener;)V

    iput-object p1, p0, Lcom/hyphenate/chat/EMChatRoomManager;->mClient:Lcom/hyphenate/chat/EMClient;

    invoke-static {}, Ljava/util/concurrent/Executors;->newCachedThreadPool()Ljava/util/concurrent/ExecutorService;

    move-result-object v0

    iput-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->threadPool:Ljava/util/concurrent/ExecutorService;

    return-void
.end method

.method static synthetic access$000(Lcom/hyphenate/chat/EMChatRoomManager;)Ljava/util/List;
    .locals 1

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListeners:Ljava/util/List;

    return-object v0
.end method

.method private handleError(Lcom/hyphenate/chat/adapter/EMAError;)V
    .locals 1

    invoke-virtual {p1}, Lcom/hyphenate/chat/adapter/EMAError;->errCode()I

    move-result v0

    if-eqz v0, :cond_0

    new-instance v0, Lcom/hyphenate/exceptions/HyphenateException;

    invoke-direct {v0, p1}, Lcom/hyphenate/exceptions/HyphenateException;-><init>(Lcom/hyphenate/chat/adapter/EMAError;)V

    throw v0

    :cond_0
    return-void
.end method


# virtual methods
.method public addChatRoomChangeListener(Lcom/hyphenate/EMChatRoomChangeListener;)V
    .locals 1

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListeners:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    return-void
.end method

.method public asyncFetchChatRoomFromServer(Ljava/lang/String;Lcom/hyphenate/EMValueCallBack;)V
    .locals 2

    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    new-instance v1, Lcom/hyphenate/chat/EMChatRoomManager$5;

    invoke-direct {v1, p0, p1, p2}, Lcom/hyphenate/chat/EMChatRoomManager$5;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;Ljava/lang/String;Lcom/hyphenate/EMValueCallBack;)V

    invoke-virtual {v0, v1}, Lcom/hyphenate/chat/EMClient;->execute(Ljava/lang/Runnable;)V

    return-void
.end method

.method public asyncFetchPublicChatRoomsFromServer(IILcom/hyphenate/EMValueCallBack;)V
    .locals 2

    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    new-instance v1, Lcom/hyphenate/chat/EMChatRoomManager$4;

    invoke-direct {v1, p0, p1, p2, p3}, Lcom/hyphenate/chat/EMChatRoomManager$4;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;IILcom/hyphenate/EMValueCallBack;)V

    invoke-virtual {v0, v1}, Lcom/hyphenate/chat/EMClient;->execute(Ljava/lang/Runnable;)V

    return-void
.end method

.method public asyncFetchPublicChatRoomsFromServer(ILjava/lang/String;Lcom/hyphenate/EMValueCallBack;)V
    .locals 2

    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    new-instance v1, Lcom/hyphenate/chat/EMChatRoomManager$3;

    invoke-direct {v1, p0, p1, p2, p3}, Lcom/hyphenate/chat/EMChatRoomManager$3;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;ILjava/lang/String;Lcom/hyphenate/EMValueCallBack;)V

    invoke-virtual {v0, v1}, Lcom/hyphenate/chat/EMClient;->execute(Ljava/lang/Runnable;)V

    return-void
.end method

.method public fetchChatRoomFromServer(Ljava/lang/String;)Lcom/hyphenate/chat/EMChatRoom;
    .locals 1

    const/4 v0, 0x0

    invoke-virtual {p0, p1, v0}, Lcom/hyphenate/chat/EMChatRoomManager;->fetchChatRoomFromServer(Ljava/lang/String;Z)Lcom/hyphenate/chat/EMChatRoom;

    move-result-object v0

    return-object v0
.end method

.method public fetchChatRoomFromServer(Ljava/lang/String;Z)Lcom/hyphenate/chat/EMChatRoom;
    .locals 2

    new-instance v0, Lcom/hyphenate/chat/adapter/EMAError;

    invoke-direct {v0}, Lcom/hyphenate/chat/adapter/EMAError;-><init>()V

    iget-object v1, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    invoke-virtual {v1, p1, v0, p2}, Lcom/hyphenate/chat/adapter/EMAChatRoomManager;->fetchChatroomSpecification(Ljava/lang/String;Lcom/hyphenate/chat/adapter/EMAError;Z)Lcom/hyphenate/chat/adapter/EMAChatRoom;

    move-result-object v1

    invoke-direct {p0, v0}, Lcom/hyphenate/chat/EMChatRoomManager;->handleError(Lcom/hyphenate/chat/adapter/EMAError;)V

    new-instance v0, Lcom/hyphenate/chat/EMChatRoom;

    invoke-direct {v0, v1}, Lcom/hyphenate/chat/EMChatRoom;-><init>(Lcom/hyphenate/chat/adapter/EMAChatRoom;)V

    return-object v0
.end method

.method public fetchPublicChatRoomsFromServer(ILjava/lang/String;)Lcom/hyphenate/chat/EMCursorResult;
    .locals 5

    new-instance v0, Lcom/hyphenate/chat/adapter/EMAError;

    invoke-direct {v0}, Lcom/hyphenate/chat/adapter/EMAError;-><init>()V

    iget-object v1, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    invoke-virtual {v1, v0}, Lcom/hyphenate/chat/adapter/EMAChatRoomManager;->fetchAllChatrooms(Lcom/hyphenate/chat/adapter/EMAError;)Ljava/util/List;

    move-result-object v1

    invoke-direct {p0, v0}, Lcom/hyphenate/chat/EMChatRoomManager;->handleError(Lcom/hyphenate/chat/adapter/EMAError;)V

    new-instance v2, Lcom/hyphenate/chat/EMCursorResult;

    invoke-direct {v2}, Lcom/hyphenate/chat/EMCursorResult;-><init>()V

    new-instance v3, Ljava/util/ArrayList;

    invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V

    invoke-interface {v1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/hyphenate/chat/adapter/EMAChatRoom;

    new-instance v4, Lcom/hyphenate/chat/EMChatRoom;

    invoke-direct {v4, v0}, Lcom/hyphenate/chat/EMChatRoom;-><init>(Lcom/hyphenate/chat/adapter/EMAChatRoom;)V

    invoke-interface {v3, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    invoke-virtual {v2, v0}, Lcom/hyphenate/chat/EMCursorResult;->setCursor(Ljava/lang/String;)V

    invoke-virtual {v2, v3}, Lcom/hyphenate/chat/EMCursorResult;->setData(Ljava/lang/Object;)V

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    invoke-interface {v0, v3}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    return-object v2
.end method

.method public fetchPublicChatRoomsFromServer(II)Lcom/hyphenate/chat/EMPageResult;
    .locals 6

    new-instance v0, Lcom/hyphenate/chat/adapter/EMAError;

    invoke-direct {v0}, Lcom/hyphenate/chat/adapter/EMAError;-><init>()V

    iget-object v1, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    invoke-virtual {v1, p1, p2, v0}, Lcom/hyphenate/chat/adapter/EMAChatRoomManager;->fetchChatroomsWithPage(IILcom/hyphenate/chat/adapter/EMAError;)Lcom/hyphenate/chat/EMPageResult;

    move-result-object v1

    invoke-direct {p0, v0}, Lcom/hyphenate/chat/EMChatRoomManager;->handleError(Lcom/hyphenate/chat/adapter/EMAError;)V

    invoke-virtual {v1}, Lcom/hyphenate/chat/EMPageResult;->getData()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/List;

    invoke-virtual {v1}, Lcom/hyphenate/chat/EMPageResult;->getPageCount()I

    move-result v1

    new-instance v2, Lcom/hyphenate/chat/EMPageResult;

    invoke-direct {v2}, Lcom/hyphenate/chat/EMPageResult;-><init>()V

    new-instance v3, Ljava/util/ArrayList;

    invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/hyphenate/chat/adapter/EMAChatRoom;

    new-instance v5, Lcom/hyphenate/chat/EMChatRoom;

    invoke-direct {v5, v0}, Lcom/hyphenate/chat/EMChatRoom;-><init>(Lcom/hyphenate/chat/adapter/EMAChatRoom;)V

    invoke-interface {v3, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    :cond_0
    invoke-virtual {v2, v1}, Lcom/hyphenate/chat/EMPageResult;->setPageCount(I)V

    invoke-virtual {v2, v3}, Lcom/hyphenate/chat/EMPageResult;->setData(Ljava/lang/Object;)V

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    invoke-interface {v0, v3}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    return-object v2
.end method

.method public getAllChatRooms()Ljava/util/List;
    .locals 1

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRooms:Ljava/util/List;

    invoke-static {v0}, Ljava/util/Collections;->unmodifiableList(Ljava/util/List;)Ljava/util/List;

    move-result-object v0

    return-object v0
.end method

.method public getChatRoom(Ljava/lang/String;)Lcom/hyphenate/chat/EMChatRoom;
    .locals 2

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->emaObject:Lcom/hyphenate/chat/adapter/EMAChatRoomManager;

    invoke-virtual {v0, p1}, Lcom/hyphenate/chat/adapter/EMAChatRoomManager;->getChatroom(Ljava/lang/String;)Lcom/hyphenate/chat/adapter/EMAChatRoom;

    move-result-object v1

    if-nez v1, :cond_0

    const/4 v0, 0x0

    :goto_0
    return-object v0

    :cond_0
    new-instance v0, Lcom/hyphenate/chat/EMChatRoom;

    invoke-direct {v0, v1}, Lcom/hyphenate/chat/EMChatRoom;-><init>(Lcom/hyphenate/chat/adapter/EMAChatRoom;)V

    goto :goto_0
.end method

.method importChatRoom(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)V
    .locals 0

    return-void
.end method

.method public joinChatRoom(Ljava/lang/String;Lcom/hyphenate/EMValueCallBack;)V
    .locals 2

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->threadPool:Ljava/util/concurrent/ExecutorService;

    new-instance v1, Lcom/hyphenate/chat/EMChatRoomManager$1;

    invoke-direct {v1, p0, p1, p2}, Lcom/hyphenate/chat/EMChatRoomManager$1;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;Ljava/lang/String;Lcom/hyphenate/EMValueCallBack;)V

    invoke-interface {v0, v1}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;

    return-void
.end method

.method public leaveChatRoom(Ljava/lang/String;)V
    .locals 2

    invoke-virtual {p0, p1}, Lcom/hyphenate/chat/EMChatRoomManager;->getChatRoom(Ljava/lang/String;)Lcom/hyphenate/chat/EMChatRoom;

    move-result-object v0

    if-nez v0, :cond_1

    :cond_0
    :goto_0
    return-void

    :cond_1
    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v1

    invoke-virtual {v1}, Lcom/hyphenate/chat/EMClient;->getOptions()Lcom/hyphenate/chat/EMOptions;

    move-result-object v1

    invoke-virtual {v1}, Lcom/hyphenate/chat/EMOptions;->isChatroomOwnerLeaveAllowed()Z

    move-result v1

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMChatRoom;->getOwner()Ljava/lang/String;

    move-result-object v0

    if-nez v1, :cond_2

    invoke-static {}, Lcom/hyphenate/chat/EMSessionManager;->getInstance()Lcom/hyphenate/chat/EMSessionManager;

    move-result-object v1

    invoke-virtual {v1}, Lcom/hyphenate/chat/EMSessionManager;->getLastLoginUser()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_0

    :cond_2
    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMClient;->chatManager()Lcom/hyphenate/chat/EMChatManager;

    move-result-object v0

    const/4 v1, 0x1

    invoke-virtual {v0, p1, v1}, Lcom/hyphenate/chat/EMChatManager;->deleteConversation(Ljava/lang/String;Z)Z

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->threadPool:Ljava/util/concurrent/ExecutorService;

    new-instance v1, Lcom/hyphenate/chat/EMChatRoomManager$2;

    invoke-direct {v1, p0, p1}, Lcom/hyphenate/chat/EMChatRoomManager$2;-><init>(Lcom/hyphenate/chat/EMChatRoomManager;Ljava/lang/String;)V

    invoke-interface {v0, v1}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;

    goto :goto_0
.end method

.method onLogout()V
    .locals 1

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListeners:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    return-void
.end method

.method public removeChatRoomChangeListener(Lcom/hyphenate/EMChatRoomChangeListener;)V
    .locals 1

    iget-object v0, p0, Lcom/hyphenate/chat/EMChatRoomManager;->chatRoomListeners:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    return-void
.end method
